<script setup lang="ts">
import {BluePrintApi, BlueprintDo} from "@/views/ai/agent/x6/api/blue-print-api";
import {FormInstance} from "element-plus";
const show=ref(false);
const formData=ref<BlueprintDo>({})
const emits = defineEmits<{
  (e:'ok')
}>();
const open=(b:boolean,f?:BlueprintDo)=>{
  console.log('open')
  show.value=b;
  formData.value=f||{};
}
const form=ref<FormInstance>()
const save=async ()=>{
  await form.value?.validate()
  const api=formData.value.id?BluePrintApi.save:BluePrintApi.insert
  await api(formData.value)
  emits('ok')
  show.value=false
}
defineExpose({
  open
})
</script>

<template>
  <el-dialog v-model="show" title="智能体应用">
    <el-form :model="formData" ref="form" label-width="100">
      <el-form-item label="应用名称" required prop="name">
        <el-input v-model="formData.name"/>
      </el-form-item>
      <el-form-item label="应用编码" required>
        <el-input v-model="formData.code"/>
      </el-form-item>
      <el-form-item label="说明">
        <el-input type="textarea" autosize v-model="formData.remark"/>
      </el-form-item>
      <el-form-item label="标签">
        <el-input-tag v-model="formData.tags"/>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="show = false">取消</el-button>
      <el-button @click="save" type="primary">确定</el-button>
    </template>
  </el-dialog>
</template>

<style scoped lang="scss">

</style>
